<?php
// no direct access
defined('_JEXEC') or die;

require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
if ( $detect->isMobile() ) {
    include('default_mobile.php');
    return;
}

$templatepath	= JURI::base().'templates/'.JFactory::$application->getTemplate();
JPluginHelper::importPlugin('content','loadmodule');
$dispatcher	= JDispatcher::getInstance();
$db =& JFactory::getDBO();

$db->setQuery("SELECT title, introtext text, `fulltext` FROM `#__content` WHERE id=4");
$article=$db->loadObject();
$article->text=strip_tags($article->text);
$article->params=array();
$dispatcher->trigger('onContentPrepare', array ('com_content.article', &$article, &$article->params));
?>
<div class="wrapper" id="slider-demo">
	<div class="slideshow-wrapper clearfix">
		<?php echo $article->text?>
	</div>
</div>

			<div class="wrapper">
				<div class="content" id="home-page">
					<div id="welcome-box">
						<h1 style="font-size: 30px"><?php echo preg_replace("# (.+)#",' <span class="green">$1</span>',$article->title)?></h1>
						<?php echo $article->fulltext?>
					</div>
					<div class="col-wrapper clearfix">
						<div class="col-2 col-cfg">
							<div class="box-vid">
<?php
							$db->setQuery("SELECT introtext text FROM `#__content` WHERE id=1");
							$article=$db->loadObject();
							echo preg_replace("#\<p>{youtube .*?=(.+)\}</p>#",'<iframe width="470" height="265" src="//www.youtube.com/embed/$1" frameborder="0" wmode="opaque" allowfullscreen></iframe>',$article->text);
?>
							</div>
						</div>
						<div class="col-1 col-cfg" id="box-hp">
<?php
						$db->setQuery("SELECT title, introtext text FROM `#__content` WHERE id=2");
						$article=$db->loadObject();						
?>
							<h2 class="hd"><?php echo $article->title?></h2>
							<?php echo $article->text?>
							<div id="box-facebook">
								<img src="<?php echo $templatepath; ?>/img/imgFollow.png" alt="" id="img-text1">
								<a href="http://www.facebook.com/fitplan.dk" target="_blank"><img src="<?php echo $templatepath; ?>/img/imgFacebook.png" alt=""></a>
								<img src="<?php echo $templatepath; ?>/img/imgOg.png" alt="" id="img-text2">
								<a href="http://plus.google.com/u/0/117716894165331314266/posts"><img src="<?php echo $templatepath; ?>/img/imgG+.png" alt=""></a>
								<div class="clr"></div>
							</div>
						</div>
						<div class="col-1 col-cfg col-last">
							<div id="box-newsletter">
<?php
							$db->setQuery("SELECT CASE WHEN introtext<>'' THEN introtext ELSE `fulltext` END text FROM `#__content` WHERE id=3");
							$article=$db->loadObject();
							$article->params=array();
							$dispatcher->trigger('onContentPrepare', array ('com_content.article', &$article, &$article->params));
							echo $article->text;
?>
							</div>

						</div>
					</div>
				</div>
			</div>
<?php
return;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');

// If the page class is defined, add to class as suffix.
// It will be a separate class if the user starts it with a space
?>
<div class="blog-featured<?php echo $this->pageclass_sfx;?>">
<?php if ( $this->params->get('show_page_heading')!=0) : ?>
	<h1>
	<?php echo $this->escape($this->params->get('page_heading')); ?>
	</h1>
<?php endif; ?>

<?php $leadingcount=0 ; ?>
<?php if (!empty($this->lead_items)) : ?>
<div class="items-leading">
	<?php foreach ($this->lead_items as &$item) : ?>
		<div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>">
			<?php
				$this->item = &$item;
				echo $this->loadTemplate('item');
			?>
		</div>
		<?php
			$leadingcount++;
		?>
	<?php endforeach; ?>
</div>
<?php endif; ?>
<?php
	$introcount=(count($this->intro_items));
	$counter=0;
?>
<?php if (!empty($this->intro_items)) : ?>
	<?php foreach ($this->intro_items as $key => &$item) : ?>

	<?php
		$key= ($key-$leadingcount)+1;
		$rowcount=( ((int)$key-1) %	(int) $this->columns) +1;
		$row = $counter / $this->columns ;

		if ($rowcount==1) : ?>

			<div class="items-row cols-<?php echo (int) $this->columns;?> <?php echo 'row-'.$row ; ?>">
		<?php endif; ?>
		<div class="item column-<?php echo $rowcount;?><?php echo $item->state == 0 ? ' system-unpublished"' : null; ?>">
			<?php
					$this->item = &$item;
					echo $this->loadTemplate('item');
			?>
		</div>
		<?php $counter++; ?>
			<?php if (($rowcount == $this->columns) or ($counter ==$introcount)): ?>
				<span class="row-separator"></span>
				</div>

			<?php endif; ?>
	<?php endforeach; ?>
<?php endif; ?>

<?php if (!empty($this->link_items)) : ?>
	<div class="items-more">
	<?php echo $this->loadTemplate('links'); ?>
	</div>
<?php endif; ?>

<?php if ($this->params->def('show_pagination', 2) == 1  || ($this->params->get('show_pagination') == 2 && $this->pagination->get('pages.total') > 1)) : ?>
	<div class="pagination">

		<?php if ($this->params->def('show_pagination_results', 1)) : ?>
			<p class="counter">
				<?php echo $this->pagination->getPagesCounter(); ?>
			</p>
		<?php  endif; ?>
				<?php echo $this->pagination->getPagesLinks(); ?>
	</div>
<?php endif; ?>

</div>
<!--featured-->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 982967144;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>

<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/982967144/?value=0&amp;guid=ON&amp;script=0"/>
</div>
</noscript>